<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>合成</title>
    <style>
        body{margin: 0;overflow: hidden}
        #canvas{
            background: antiquewhite;
        }
    </style>
</head>
<body>
<canvas id="canvas"></canvas>
<script>
    const canvas=document.getElementById('canvas');
    //canvas充满窗口
    canvas.width=window.innerWidth;
    canvas.height=window.innerHeight;
    //画笔
    const  ctx=canvas.getContext('2d');

    /*透明度合成 globalAlpha，取值范围[0,1]*/
    ctx.globalAlpha=0.5;
    ctx.fillRect(100,100,200,200);
    ctx.fillStyle='rgba(0,0,0,0.5)';
    ctx.fillRect(150,150,200,200);



</script>
</body>
</html>
